{block name="resources"/}
{/block}
{block name="main"}
<div class="couponsDetails">
    <!-- page -->
    <div class="screen-title"><span class="text">活动信息</span></div>
    <form class="form-horizontal" role="form">
        <!--<div class="form-group mb0">
            <label class="col-sm-1 control-label">适用范围</label>
            <div class="col-sm-6">
                <p class="form-control-static" id="range"></p>
            </div>
        </div>
        <div class="form-group mb0">
            <label class="col-sm-1 control-label">活动名称</label>
            <div class="col-sm-6">
                <p class="form-control-static" id="discount_name"></p>
            </div>
        </div>
        <div class="form-group mb0">
            <label class="col-sm-1 control-label">活动折扣</label>
            <div class="col-sm-6">
                <p class="form-control-static" id="discount_num"></p>
            </div>
        </div>
        <div class="form-group mb0">
            <label class="col-sm-1 control-label">生效时间</label>
            <div class="col-sm-6">
                <p class="form-control-static" id="time"></p>
            </div>
        </div>
        <div class="form-group mb0">
            <label class="col-sm-1 control-label">活动说明</label>
            <div class="col-sm-6">
                <p class="form-control-static" id="remark"></p>
            </div>
        </div>
        <div class="form-group mb0">
            <label class="col-sm-1 control-label">活动状态</label>
            <div class="col-sm-6">
                <p class="form-control-static" id="status"></p>
            </div>
        </div>-->
            <div class="col-md-10">
                <table class="table v-table table-auto-center table-bordered">
                    <tbody>
                        <tr>
                            <input type="hidden" id="mansong_id" name="mansong_id" value="{$mansong_info['mansong_id']}">
                            <td class="col-md-3 bg-f5">
                                <div class="padding-15">
                                    <p >适用范围</p>
                                </div>
                            </td>
                            <td class="text-left">
                                <p id="range">
                                    {if condition="$mansong_info['shop_id'] neq 0"}店铺端{/if}
                                    {if condition="$mansong_info['range'] eq 1"} 自营店{/if}
                                    {if condition="$mansong_info['range'] eq 2"} 全平台 {/if}
                                </p>
                            </td>
                        </tr>
                        <tr>
                            <td class="col-md-3 bg-f5">
                                <div class="padding-15">
                                    <p>活动名称</p>
                                </div>
                            </td>
                            <td class="text-left">
                                <p id="discount_name">{$mansong_info['mansong_name']}</p>
                            </td>
                        </tr>

                        <tr>
                            <td class="col-md-3 bg-f5">
                                <div class="padding-15">
                                    <p>生效时间</p>
                                </div>
                            </td>
                            <td class="text-left">
                                <p id="time">{$mansong_info['start_time'] | timeStampTurnDate} 00:00:00 ~ {$mansong_info['end_time'] | timeStampTurnDate} 23:59:59</p>
                            </td>
                        </tr>
                        <tr class="no_sku">
                            <td class="col-md-3 bg-f5">
                                <div class="padding-15">
                                    <p>活动说明</p>
                                </div>
                            </td>
                            <td class="text-left">
                                <p id="remark">{$mansong_info['remark']}</p>
                            </td>
                        </tr>
                        <tr class="no_sku">
                            <td class="col-md-3 bg-f5">
                                <div class="padding-15">
                                    <p>活动状态</p>
                                </div>
                            </td>
                            <td class="text-left">
                                <p id="status">
                                    {if condition="$mansong_info['status'] eq 0"}未发布{/if}
                                    {if condition="$mansong_info['status'] eq 1"}正常{/if}
                                    {if condition="$mansong_info['status'] eq 3"}关闭{/if}
                                    {if condition="$mansong_info['status'] eq 4"}结束{/if}
                                </p>
                            </td>
                        </tr>
                        <tr class="no_sku">
                            <td class="col-md-3 bg-f5">
                                <div class="padding-15">
                                    <p>商品范围</p>
                                </div>
                            </td>
                            <td class="text-left">
                                <p id="remark">{if condition="$mansong_info['range_type'] eq 1"}全部商品{else}部分商品{/if}</p>
                            </td>
                        </tr>
                        <tr class="no_sku">
                            <td class="col-md-3 bg-f5">
                                <div class="padding-15">
                                    <p>优惠规则</p>
                                </div>
                            </td>
                            <td class="text-left">
                                <p id="remark">{$mansong_rule}</p>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="form-group"></div>
    </form>
    {if condition="$mansong_info['range_type'] eq 0"}
    <div class="screen-title"><span class="text">活动商品</span></div>

    <!--表格-->
    <table class="table v-table table-auto-center">
        <thead>
        <tr>
            <th class="col-md-6">商品信息</th>
            <th>库存</th>
            <th>店铺</th>
        </tr>
        </thead>
        <tbody class="trs" id="seleted_goods_list">
        </tbody>
    </table>
    {/if}
    <div class="cd-back" >
        <a href="javascript:window.history.go(-1)" style="text-align: center;color:white;background: #2c9cf0;padding: 10px;margin-left:10%;border-radius: 5px;">返回</a>
    </div>
    <!-- page end -->
</div>
{/block}
{block name="script"}
<script>
  require(['utilAdmin','util'], function (utilAdmin,util) {
      var range_type = {$mansong_info['range_type']};
      if(range_type==0){
          $(function () {
              util.initPage(LoadingInfo);
          })
      }

      function LoadingInfo(page_index, range_type) {
          var range = $('input[name="range"]:checked').val();
          var $goodsArr = new Array();
          var search_text = $("#search_text").val();
          $("#seleted_goods_list").html('');
          if ($("input[name='range_type']:checked").val() == 0) {
              $('#range_type').removeClass('hidden');
          } else {
              $('#range_type').addClass('hidden');
          }

          $.ajax({
              type: "post",
              url: "{:__URL('PLATFORM_MAIN/goods/getserchgoodslist')}",
              data: {
                  "page_index": page_index,
                  "page_size": $("#showNumber").val(),
                  "search_text": search_text,
                  "shop_range_type": range
              },
              success: function (data) {
                  var data = {$goods_list};
                  $data_array = data['data'];

                  //动态添加已选择的
                  var select = '';
                  for (var i = 0; i < data.length; i++) {
                      select += '<tr id="html_' + data[i]["goods_id"] + '" goodsid="' + data[i]["goods_id"] + '">';
                      select += '<td>';
                      select += '<div class="media text-left">';
                      select += '<div class="media-left">';
                      select += '<div>';
                      if (data[i]["picture_info"]['pic_cover']) {
                          select += '<img src="' + __IMG(data[i]["picture_info"]["pic_cover"]) + '" width="60" height="60"></div></th>';
                      } else {
                          select += '<img src="__ROOT__/" width="60" height="60"></div></th>';
                      }
                      select += '</div>';
                      select += '<div class="media-body max-w-300">';
                      select += '<div class="line-2-ellipsis"><a href="' + __URLS('SHOP_MAIN/goods/goodsinfo&goodsid=' + data[i]["goods_id"]) + '" target="_blank" class="new-window" title="' + data[i]["goods_name"] + '">' + data[i]["goods_name"] + '</a></div>';
                      select += '</div>';
                      select += '</div>';
                      select += '</td>';
                      select += '<td>';
                      if(data[i]["stock"]!=null){
                          select += data[i]["stock"];
                      }else{
                          select += '0';
                      }
                      select += '</td>';
                      select += '<td>';
                      select += data[i]["shop_name"];
                      select += '</td>';
                      select += '</tr>';

                  }
                  $('#seleted_goods_list').html(select);
              }

          })
      }
  });
</script>
{/block}